From: Keir Fraser Date: Thu, 23 Oct 2008 14:34:27 +0000 (+0100) Subject: x86: Dom0 builder must run on a valid GDT at all times. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14054^2~40 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=99e789d682ede5d680d04f3043aa128895ea2f97;p=xen.git x86: Dom0 builder must run on a valid GDT at all times. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 5bd7714ba0..f2558a4944 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -194,6 +194,32 @@ static void __init process_dom0_ioports_disable(void) } } +/* We run on dom0's page tables for the final part of the build process. */ +static void dom0_pt_enter(struct vcpu *v) +{ + struct desc_ptr gdt_desc = { + .limit = LAST_RESERVED_GDT_BYTE, + .base = (unsigned long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY) + }; + + asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); + local_irq_disable(); + write_ptbase(v); +} + +/* Return to idle domain's page tables. */ +static void dom0_pt_exit(void) +{ + struct desc_ptr gdt_desc = { + .limit = LAST_RESERVED_GDT_BYTE, + .base = GDT_VIRT_START(current) + }; + + write_ptbase(current); + local_irq_enable(); + asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); +} + int __init construct_dom0( struct domain *d, unsigned long _image_start, unsigned long image_len, @@ -700,14 +726,12 @@ int __init construct_dom0( (void)alloc_vcpu(d, i, i % num_online_cpus()); /* Set up CR3 value for write_ptbase */ - if ( paging_mode_enabled(v->domain) ) + if ( paging_mode_enabled(d) ) paging_update_paging_modes(v); else update_cr3(v); - /* Install the new page tables. */ - local_irq_disable(); - write_ptbase(v); + dom0_pt_enter(v); /* Copy the OS image and free temporary buffer. */ elf.dest = (void*)vkern_start; @@ -804,9 +828,7 @@ int __init construct_dom0( xlat_start_info(si, XLAT_start_info_console_dom0); #endif - /* Reinstate the caller's page tables. */ - write_ptbase(current); - local_irq_enable(); + dom0_pt_exit(); #if defined(__i386__) /* Destroy low mappings - they were only for our convenience. */